<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block data-th-replace="/adminlte/base::base-head"></th:block>
    <link rel="stylesheet" href="/plugins/datatables-bs4/css/dataTables.bootstrap4.css">
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="modal fade" id="dialog-server-add">
    <div class="modal-dialog">
        <div class="modal-content"
             style="border-radius: 5px; margin-top: 10%; border-radius: 5px;">
            <div class="modal-header">
                <h4 class="modal-title">新增服务器</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form role="form" action="/file/servers" method="post" data-dialog-close="#dialog-server-add">
                <div class="modal-body">
                    <div class="form-group">
                        <label><span class="text-red">*</span> 服务器名称</label>
						<input type="text" class="form-control" placeholder="服务器名称" name="name" autofocus="autofocus" required="required">
                    </div>
                    <div class="form-group">
                        <label><span class="text-red">*</span> 服务器权重</label>
						<input type="text" class="form-control" placeholder="服务器权重" name="priority" required="required">
                    </div>
                    <div class="form-group">
                        <label><span class="text-red">*</span> 服务器地址</label>
						<input type="text" class="form-control" placeholder="服务器地址" name="host" required="required">
                    </div>
                    <div class="form-group">
                        <label><span class="text-red">*</span> 服务器用户ID</label>
						<input type="text" class="form-control" placeholder="服务器用户ID" name="user_id" required="required">
                    </div>
                    <div class="form-group">
                        <label><span class="text-red">*</span> 服务器用户密钥</label>
						<input type="text" class="form-control" placeholder="服务器用户密钥" name="aes_key" required="required">
                    </div>
                    <div class="form-group">
                        <label><span class="text-red">*</span> 服务器用户偏移</label>
						<input type="text" class="form-control" placeholder="服务器用户偏移" name="aes_iv" required="required">
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default float-left" data-dismiss="modal" style="width: 100px" type="button">取消</button>
                    <button class="btn btn-success float-right" style="width: 100px" type="submit">确定</button>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="wrapper">
    <th:block data-th-replace="/adminlte/base::base-navbar"></th:block>
    <th:block data-th-replace="/adminlte/base::base-main-sidebar"></th:block>
    <div class="content-wrapper">
        <th:block data-th-replace="/adminlte/base::base-content-header"></th:block>
        <section class="content">
            <div class="container-fluid">
                <div class="card">
                    <div class="card-header">
                        <div class="row mt-2">
                            <button class="btn btn-app" data-dialog="show" data-url="#dialog-server-add">
                                <i class="fas fa-plus text-blue"></i> 新增服务器
                            </button>
                        </div>
                    </div>

                    <div class="card-body table-responsive">
                        <div class="table-responsive">
                            <table id="role-table" class="table table-bordered table-hover" data-url="/file/servers/">
                                <colgroup>
                                    <col width="50"/>
                                    <col/>
                                    <col width="80"/>
                                    <col width="80"/>
                                    <col width="300"/>
                                    <col width="200"/>
                                    <col width="200"/>
                                    <col width="80"/>
                                    <col width="80"/>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>名称</th>
                                    <th>权重</th>
                                    <th>用户</th>
                                    <th>地址</th>
                                    <th>密钥</th>
                                    <th>偏移</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
									<tr data-th-each="server : ${serverList}" th:data-key="${server.id}" th:with="flag=${fileClientUtils.test(server.id)}, class=${flag?'':'text-danger'}" >
										<td data-th-utext="${server.id}" data-th-class="${class}">id
										</td>
										<td data-th-utext="${server.name}" data-th-class="${class}" data-col-name="name"
											contenteditable="true">名称
										</td>
										<td data-th-utext="${server.priority}" data-th-class="${class}" data-col-name="priority"
											contenteditable="true">优先级
										</td>
										<td data-th-utext="${server.userId}" data-th-class="${class}" data-col-name="userId"
											contenteditable="true">用户ID
										</td>
										<td data-th-utext="${server.host}" data-th-class="${class}" data-col-name="host"
											contenteditable="true">服务器地址
										</td>
										<td data-th-utext="${server.aesKey}" data-th-class="${class}" data-col-name="aesKey"
											contenteditable="true">服务器密钥
										</td>
										<td data-th-utext="${server.aesIv}" data-th-class="${class}" data-col-name="aesIv"
											contenteditable="true">服务器偏移
										</td>
										<td data-th-utext="${flag?'正常':'异常'}" data-th-class="${class}">服务器偏移
										</td>
										<td class="td-manage">
											<a title="删除服务器"
											   data-dialog="confirm"
											   data-url="/file/servers/"
											   data-method="delete"
											   th:data-path="${server.id}"
											   data-dialog-t-msg="您确定要删除当前服务器吗？" style="margin-left: 10px;">
												<i class="fas fa-trash text-blue"></i>
											</a>
										</td>
									</tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <th:block data-th-replace="/adminlte/base::base-footer"></th:block>
    <th:block data-th-replace="/adminlte/base::base-control-sidebar"></th:block>
</div>
<script src="/plugins/datatables/jquery.dataTables.js"></script>
<script src="/plugins/datatables-bs4/js/dataTables.bootstrap4.js"></script>
<script src="/kaibes/js/table-data.js"></script>
<script src="/kaibes/js/table-update.js"></script>
<script type="text/javascript">
    dataTable(0, [5, 6, 7]);
</script>
</body>
</html>